package Observer.Stock;

import java.util.ArrayList;
import java.util.List;

public class SellHolder implements IStockHolder{
    private List<AbstractStockPrice> attentionList;
    private String name;

    public SellHolder(String name)
    {
        attentionList = new ArrayList<AbstractStockPrice>();
        this.name = name;
    }

    @Override
    public void update(AbstractStockPrice asp) {
        if(attentionList.contains(asp))
        {
            System.out.println(name);

            System.out.print(asp.code + ":");
            System.out.print("原价:" + asp.oldPrice + "-现价:" + asp.price);

            if(asp.getPrice() - asp.getOldPrice() > 0)
            {
                System.out.println("涨了，哭~");
            }
            else
            {
                System.out.println("跌了，爽！");
            }
        }
    }

    @Override
    public void addHolder(AbstractStockPrice asp) {
        attentionList.add(asp);
        asp.add(this);
    }
}
